package com.zxx.pattern.statePattern.state2;

/**
 * @author zxx on 2021/1/18
 */
public class Room2 {//implements State3

    //三个状态
    private State2 freeTimeState;   //空闲
    private State2 bookedState;     //预定
    private State2 checkInState;    //入住

    private State2 state2;

    public Room2() {
        this.freeTimeState = new FreeTimeState(this);
        this.bookedState = new BookedState(this);
        this.checkInState = new CheckInState(this);

        //初始状态为空闲
        state2 = freeTimeState;
    }

    //--------------执行动作----------------------
    //预定房间
    public void bookRoom() {
        state2.bookRoom();
    }

    /**
     * 退订房间
     */
    public void unsubscribeRoom() {
        state2.unsubscribeRoom();
    }

    /**
     * 入住
     */
    public void checkInRoom() {
        state2.checkInRoom();
    }

    /**
     * 退房
     */
    public void checkOutRoom() {
        state2.checkOutRoom();
    }

    public String toString(){
        return "该房间的状态是:"+getState2().getClass().getName();
    }

    //--------------执行动作 End----------------------


    //---------------getter和setter方法--------------------


    public State2 getFreeTimeState() {
        return freeTimeState;
    }

    public void setFreeTimeState(State2 freeTimeState) {
        this.freeTimeState = freeTimeState;
    }

    public State2 getBookedState() {
        return bookedState;
    }

    public void setBookedState(State2 bookedState) {
        this.bookedState = bookedState;
    }

    public State2 getCheckInState() {
        return checkInState;
    }

    public void setCheckInState(State2 checkInState) {
        this.checkInState = checkInState;
    }

    public State2 getState2() {
        return state2;
    }

    public void setState2(State2 state2) {
        this.state2 = state2;
    }
}
